//
//  GTCategoryCell.m
//  GiftTalk
//
//  Created by Wan on 16/4/8.
//  Copyright © 2016年 Wan. All rights reserved.
//

#import "GTCategoryCell.h"
#import "GTCategory.h"

@interface GTCategoryCell()
@property (weak, nonatomic) IBOutlet UIView *selectedIndicatorView;
@end

@implementation GTCategoryCell

- (void)awakeFromNib {
    // Initialization code
    
//    self.backgroundColor = GTBackgroundColor;
}

+ (instancetype)cellWithTableView:(UITableView *)tabelView {
    GTCategoryCell *categoryCell = [tabelView dequeueReusableCellWithIdentifier:reuseCategoryCell];
    if (!categoryCell) {
        categoryCell = [self viewFromXib];
    }
    
    return categoryCell;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    // 重新调整 textLabel 内部的 frame
    self.textLabel.y = 5;
    self.textLabel.height = self.contentView.height - 2 * self.textLabel.y;
    self.textLabel.font = [UIFont systemFontOfSize:15.0];
    self.textLabel.textAlignment = NSTextAlignmentCenter;
}

- (void)setCategory:(GTCategory *)category {
    _category = category;
    
    self.textLabel.text = category.name;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
    self.selectedIndicatorView.hidden = !selected;
    self.textLabel.textColor = selected ? GTRGBColor(219, 20, 25) : GTRGBColor(78, 78, 78);
    self.backgroundColor = selected ? [UIColor whiteColor] : GTRGBColor(250, 250, 250);
}

@end
